package com.dashboard.giangday;


import com.lb.jwitter.connectDatabase.ConnectTTGD;
import com.opensymphony.xwork2.Action;

public class BatThuongAction {

	private String jsonData;
	public String getJsonData() {
		return jsonData;
	}


	public void setJsonData(String jsonData) {
		this.jsonData = jsonData;
	}
	////////////////////////////////////////////////////////
	private String namHoc;

	public String getNamHoc() {
		return namHoc;
	}


	public void setNamHoc(String namHoc) {
		this.namHoc = namHoc;
	}
	/////////////////////////////////////////////////////////
	private String hocKy;

	public String getHocKy() {
		return hocKy;
	}


	public void setHocKy(String hocKy) {
		this.hocKy = hocKy;
	}
	/////////////////////////////////////////////////////////
	


	public String execute() throws Exception
	{
		ConnectTTGD conn= new ConnectTTGD();
		if(conn.getConnection()!=null){
			//namHoc="2014-2015";
			//hocKy="1";
			
			//if(namHoc==null||namHoc.length()<1){
			//	return Action.ERROR;
			//}
			if(hocKy==null||hocKy.length()<1){
				return Action.ERROR;
			}
			
			//hocKy  20141
			int nam = Integer.parseInt(hocKy.substring(0, 4));
			namHoc = nam+"-"+ (nam+1);
			hocKy = hocKy.substring(4);
			
			//Lay ve danh sach cac giang vien cua tat ca cac khoa ma co so tiet nghi day >= 10%
			String query="select A.maCb, A.tenCb, B.tenKhoa, A.pTramND, A.maMonhoc,A.tenMonhoc"
					+" from"
					+" (select distinct maCb, tenCb, tenKhoa, pTramND, maMonhoc, tenMonhoc  from thoikhoabieu_view where namhoc='"+namHoc+"' and hocky="+hocKy+" ) A,"
					+" cbgd_view B"
					+" where A.maCb=B.maCb and A.pTramND>=10 order by A.pTramND desc";
			
			//[{"maCb":"5690","tenCb":"Nguyen Van","tenKhoa":"Khoa Hoc MT","pTramND":"30","maMonhoc":"MH1","tenMonhoc":"Mon Hoc 1"}]
			jsonData=conn.getJSonData(query);
			
		}
		conn.closeConnection();
		return Action.SUCCESS;

	}

	
	
}
